<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Link extends Model {
	
	protected $guarded = array('id');
	
	public static $enable = [
		'1' => '显示',
		'0' => '隐藏',
	];
	
	public function getDefaultOrder() {
		$links = Link::all()->count();
		return ($links +1);
	}
	
	public function getEnableEx() {
		return $this->enable ? '显示' : '隐藏'; 		
	}
	
	public static $rules = [
		'name' => 'required',
		'link' => 'required',
	];
	
	public static $msgs = [
		'name.required' => '链接名称不能为空',
		'link.required' => '链接地址不能为空',
	];
}
